package cn.biz.imp;

import java.util.List;

import cn.biz.OrdergoodsBiz;
import cn.dao.OrdergoodsDao;
import cn.entity.Ordergoods;
import cn.entity.Orders;

public class OrdergoodsBizImp implements OrdergoodsBiz {
	private OrdergoodsDao ordergoodsDao;

	public OrdergoodsDao getOrdergoodsDao() {
		return ordergoodsDao;
	}

	public void setOrdergoodsDao(OrdergoodsDao ordergoodsDao) {
		this.ordergoodsDao = ordergoodsDao;
	}

	@Override
	public String insert(Ordergoods ordergoods) {
		String result = "error";
		try {
			ordergoodsDao.insert(ordergoods);
			result = "success";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public String delete(Ordergoods ordergoods) {
		String result = "error";
		try {
			ordergoodsDao.delete(ordergoods);
			result = "success";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public String update(Ordergoods ordergoods) {
		String result = "error";
		try {
			ordergoodsDao.update(ordergoods);
			result = "success";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public List query(Orders orders) {
		Ordergoods ordergoods = new Ordergoods();
		ordergoods.setOrders(orders);
		return ordergoodsDao.query(ordergoods);
	}

	@Override
	public List getAll() {
		return ordergoodsDao.getAll();
	}

	@Override
	public Ordergoods getOrdergoodsById(Integer id) {
		return ordergoodsDao.getOrdergoodsById(id);
	}

	@Override
	public List getOrdergoodsByOrderId(Integer id) {
		// TODO Auto-generated method stub
		return ordergoodsDao.getOrdergoodsByOrderId(id);
	}

}
